<template>
  <div>

    <el-row>
      <el-col :span="24" id="UserManagement1">

        <div id="UserManagement2">
          <el-input v-model="param.userName" placeholder="请输入姓名" style="width: 20%;"></el-input>
          <el-button type="primary" @click="search" round>搜索</el-button>
        </div>

        <div style="height: 20px;"></div>
        <el-table :data="page.records" border>

          <el-table-column prop="userId" label="用户ID" width="65">
          </el-table-column>
          <el-table-column prop="userImage" label="用户头像" width="130">
            <template #default="scope">
              <img :src="scope.row.userImage" alt="用户头像" style="max-width: 110px; max-height: 110px">
            </template>
          </el-table-column>
          <el-table-column prop="userName" label="用户名" width="110">
          </el-table-column>
          <el-table-column prop="userNickname" label="昵称" width="110">
          </el-table-column>
          <el-table-column prop="userPhone" label="手机" width="120">
          </el-table-column>
          <el-table-column prop="userEmail" label="邮箱" width="170">
          </el-table-column>
          <el-table-column prop="userState" label="账户状态" width="90">
            <template slot-scope="scope">
              <template v-if="scope.row.userState == 0">
                注销
              </template>
              <template v-if="scope.row.userState == 1">
                正常
              </template>
              <template v-else>
                禁言
              </template>
            </template>
          </el-table-column>
          <el-table-column prop="userRemark" label="备注" width="250">
          </el-table-column>




        </el-table>

        <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
          :current-page="page.pageNum" :page-sizes="[1, 2, 3, 5]" :page-size="page.pageSize"
          layout="total, sizes, prev, pager, next, jumper" :total="page.total">
        </el-pagination>

      </el-col>
    </el-row>
  </div>
</template>

<script>
  export default {
    name: "UserManagement",
    data() {
      return {
        page: {},
        param: {
          userName: "",
          pageNum: 1,
          pageSize: 5,
        },
      }
    },
    methods: {
      //搜索按钮
      search() {
        this.param.pageNum = 1;
        this.loadAllUser();
      },
      //分页的方法
      handleSizeChange(val) {
        this.param.pageSize = val;
        this.loadAllUser();
      },
      handleCurrentChange(val) {
        this.param.pageNum = val;
        this.loadAllUser();
      },
      loadAllUser() {
        this.$http.get("/account/yUser/pageAllUser", {
          params: this.param
        }).then(resp => {
          this.page = resp.data.data;
        })
      }
    },
    created() {
      this.loadAllUser();
    }
  }
</script>

<style>
  #UserManagement2 {
    margin-left: -420px;
    line-height: 100%;
    width: 100%
  }

  #UserManagement1 {
    line-height: 100%;
    width: 100%
  }
</style>
